<template>
  <a-modal
      v-model:visible="visible"
      :title="title"
      @ok="handleOk"
      :loading="loading"
  >
    <role-form ref="formRef" :formData="formData"  ></role-form>
  </a-modal>
</template>
<script lang="ts" setup>
import { Ref, ref } from 'vue'
import {  message } from 'ant-design-vue'
import { saveRole } from '@/api/sys-role'
import { useModalForm } from '@/modules/use-modules'
import RoleForm from './RoleForm.vue'
import {changList } from '@/modules/list'
const formRef = ref<InstanceType<typeof RoleForm>>()
const {
  formData,
  loading,
  visible,
  title,
  open,
  close
} = useModalForm({}, async (data: any) => {  return {
    ...data,
  }})

const emits = defineEmits(['ok','getformData'])
const handleOk = async () => {
//   await formRef.value.validate()
//   await saveRole(formData.value)
  console.log(formRef.value,'edit')
  changList(formRef.value?.getformData())
  message.success('操作成功')
  emits('ok')
  close()
}

defineExpose({ open })
</script>
